home *** CD-ROM | disk | FTP | other *** search
- Path: news2.noc.netcom.net!news
- From: Tarang Deshpande <tarang@willows.com>
- Newsgroups: comp.lang.c
- Subject: Re: Q about the float point format......
- Date: Tue, 19 Mar 1996 16:45:29 -0800
- Organization: NETCOM Network Operations
- Message-ID: <314F5529.112@willows.com>
- References: <s3032089.15.314E68DD@sparc13.ncu.edu.tw>
- NNTP-Posting-Host: daffy.willows.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
-
- Alexander PeaceLand wrote:
- >
- > Could I dynamicly set the digits after the float POINT?
- >
- > In other word... I use printf to print the float point number
- > like 123.456789 but in the other time i only
- > want to print 123.456 or 123.4
-
-
- You can actually specify the field width and the number of decimals by
- using printf ( "%*.*f", Width, Decimals, FloatNumber ); where, Width
- is an int that specifies the total width of the field, Decimals is
- also an int that specifies the number of dicimal places that are to
- be printed, and FloatNumber is the actual value you wish to print.
-
- If Width is negative then the print out is left justified rather than
- right. If width is left out then the width becomes whatever is
- necessary to print the value. You can also use 0* to mean zero fill
- blank spaces.
-